<%@page pageEncoding="UTF-8" contentType="text/html; utf-8" isELIgnored="false" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
    <meta name="description" content="description of your site" />
    <meta name="author" content="author of the site" />
    <title>管理员修改密码</title>
    <link rel="stylesheet" href="../css/bootstrap.css" />
    <link rel="stylesheet" href="../css/bootstrap-responsive.css" />
    <link rel="stylesheet" href="../css/styles.css" />
    <link rel="stylesheet" href="../css/toastr.css" />
    <link rel="stylesheet" href="../css/fullcalendar.css" />
    <script src="../js/jquery.min.js"></script>
    <script src="../js/bootstrap.js"></script>
    <script src="../js/jquery.knob.js"></script>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script src="../js/jquery.sparkline.min.js"></script>
    <script src="../js/toastr.js"></script>
    <script src="../js/jquery.tablesorter.min.js"></script>
    <script src="../js/jquery.peity.min.js"></script>
    <script src="../js/fullcalendar.min.js"></script>
    <script src="../js/gcal.js"></script>
    <script src="../js/setup.js"></script>
    <script type="text/javascript">
        function confirm(frm){

            return
        }
        $(function () {
            //鼠标离开时
            $("#originPwd").change(function () {
                let regExp = /^[A-Z][a-zA-Z0-9_$]{7,15}$/ //6-16位字母开头，数字下划线组合

                if (regExp.test($("#originPwd").val())){

                    $("#updateAdmin").attr("class","btn btn-success")
                }else {
                    $("#updateAdmin").attr("class","btn btn-success disabled")
                }
                $.ajax({
                    url:"getOriginPwd?id="+ $("#hiddenid").val() +" &pwd="+$("#originPwd").val(),
                    // dataType:"json",
                    success(data){
                        console.log(data);
                        if (data == "密码验证成功!"){
                            $("#pwdMsg").attr("class","text-success")
                        }else {
                            $("#pwdMsg").attr("class","text-error")
                        }

                        $("#pwdMsg").html(data);
                    }
                });
            });
        })
    </script>
</head>
<body>
<!-- header -->
<%@include file="../header.jsp"%>
<!-- End header -->

<div class="page">
    <div class="page-container">
        <div class="container">
            <div class="row">
                <div class="span12">
                    <h4 class="header">修改管理员信息</h4>
                    <form action="updateAdmin" method="post" >
                        <table class="table table-striped sortable">
                            <thead>
                            </thead>
                            <tbody>
                            <tr>
                                <th>管理员ID</th>
                                <td>${admin.id}<input id="hiddenid" type="hidden" name="id" value="${admin.id}"></td>

                            </tr>

                            <tr>
                                <th>管理员账号</th>
                                <td><input type="text" name="username"
                                           value="${admin.adminName}" readonly/></td>
                            </tr>

                            <tr>
                                <th>原始密码</th>
                                <td><input id="originPwd" type="password" /><span id="pwdMsg" ></span></td>
                            </tr>
                            <tr>
                                <th>新密码</th>
                                <td><input type="password" name="adminPassword"/></td>
                            </tr>
                            <tr>
                                <th>确认新密码</th>
                                <td><input type="password" name="confirmpwd"/></td>
                            </tr>
                            <tr>

                                <td></td>
                                <td>
                                    <input id="updateAdmin" class="btn btn-success disabled" type="submit" value="修改" />&nbsp;&nbsp;&nbsp;
                                    <input class="btn btn-danger" type="reset" value="重置" /></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>

                            </tbody>
                        </table>
                    </form>

                </div>
            </div>
        </div>

    </div>
</div>
<!--footer-->
<%@include file="../footer.jsp"%>
<!--end footer-->

</body>
<script src="../js/d3-setup.js"></script>
<script>
    protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
    address = protocol + window.location.host + window.location.pathname
        + '/ws';
    socket = new WebSocket(address);
    socket.onmessage = function(msg) {
        msg.data == 'reload' && window.location.reload()
    }
</script>
</html>